package com.example.amqp.producer.service;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class Sender {

    @Autowired
    private AmqpTemplate amqpTemplate;

    @Autowired
    private Queue queue;

    @Scheduled(cron = "* * * * * ?")
    public void send(){

        String message = "Hello World!";
        amqpTemplate.convertAndSend(queue.getName(), message);

        System.out.println("Sent-------: " + message);

    }

}
